<template>
  <div>
    <h2>结合vuex 展示</h2>
    <ul>
      <li v-for="item of list" :key="item.id">
        <router-link :to="{
          name: 'messageDetail',
          query: {
            id: item.id
          }
        }">
          {{item.title}}
        </router-link>
        <button @click="showPush(item.id)">push查看</button>
        <button @click="showReplace(item.id)">replace查看</button>
        <input type="text">
      </li>
    </ul>
    <hr>
    <router-view></router-view>
  </div>
</template>

<script>
import { mapState } from 'vuex';
export default {
  name: 'MessageView',
  computed: {
    ...mapState('message', ['list', 'current'])
  },
  methods: {
    showPush(id) {
      this.$router.push({
        name: 'messageDetail',
        query: {
          id
        }
      })
    },
    showReplace(id) {
      this.$router.replace({
        name: 'messageDetail',
        query: {
          id
        }
      })
    }
  }
}
</script>

<style>

</style>